/////precompiled////////
#include "precompiled.h"
////////////////////////


#include "prs_GrfColor.h"
using namespace prs;

// TRuleGrfColor //////////////////////////////////////////////////////////////

//
TRuleGrfColor::TRuleGrfColor(snt::text::TContext &Context,svl::TVariant &VColor)
:vColor(VColor)
{
  snt::TFVoid          F;
  snt::TReturn         Return;
  snt::text::TSequence T(Context);
  snt::text::TNumber   N(Context);

  vThis = this;

  this->Name(GetClassName())
  | T.New("color") & T.New("=") & Rrgb.New() & Return.New()
  ;
  
  Rrgb
  |   N.New(vR) & T.New(",") 
    & N.New(vG) & T.New(",") 
    & N.New(vB) & F.New(FColor,vThis,vR,vG,vB)
    & Return.New()
  ;
}

//
grf::TColor &TRuleGrfColor::GetColor()
{
  grf::TColor *Color = dynamic_cast<grf::TColor*>(vColor.Pointer()); 
  
  if (!Color) { 
    Except("GetColor[!Color]");
  }
  return *Color;
}

//
void TRuleGrfColor::FColor(snt::TParams &Params) 
{ 
  GetThis(Params[0]).GetColor() = grf::TColor(
    Params[1].Integer(),Params[2].Integer(),Params[3].Integer()
  ); 
}
